package com.guxingke.gblog.controller.back;

import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.guxingke.gblog.controller.BaseController;
import com.guxingke.gblog.util.PictureUtil;
import com.guxingke.gblog.util.PropertiesUtil;

@Controller
@RequestMapping("/manage")
public class ManageController extends BaseController {

	@RequestMapping
	public ModelAndView home(HttpSession session) {
		ModelAndView mav = new ModelAndView();

		String imageBasePath = session.getServletContext().getRealPath("image");

		session.setAttribute(
				"articleImages",
				PictureUtil.getPictures(imageBasePath,
						PropertiesUtil.getValue("articlePicturePath")));
		session.setAttribute(
				"userImages",
				PictureUtil.getPictures(imageBasePath,
						PropertiesUtil.getValue("userPicturePath")));

		session.setAttribute("categories", categoryService.getCategories());

		mav.addObject("mainPage", "manage/detail.jsp");
		mav.setViewName("manage");
		return mav;
	}
}
